﻿using GC_VKMD.MusicDownloaderClient.Abstractions.Interfaces.Helpers;

namespace GC_VKMD.MusicDownloaderClient.Helpers
{
	public static class ApplicationLogger
	{
		#region Variables

		private static ILogger _logger;

		private static bool? _isLogProcessInfoMessages;
		private static bool? _isLogWarning;
		private static bool? _isLogErrors;

		private static bool _isNeedReInitLogger;

		#endregion

		#region Properties

		public static ILogger Logger
		{
			get
			{
				if (_logger != null && !_isNeedReInitLogger) return _logger;

				_logger = new NLogLogger(_isLogProcessInfoMessages ?? true, _isLogWarning ?? true, _isLogErrors ?? true);
				_isNeedReInitLogger = false;

				return _logger;
			}
		}

		public static bool? IsLogProcessInfoMessages
		{
			get { return _isLogProcessInfoMessages; }
			set
			{
				if (_isLogProcessInfoMessages != value)
					_isNeedReInitLogger = true;
				_isLogProcessInfoMessages = value;
			}
		}

		public static bool? IsLogWarning
		{
			get { return _isLogWarning; }
			set
			{
				if (_isLogWarning != value)
					_isNeedReInitLogger = true;
				_isLogWarning = value;
			}
		}

		public static bool? IsLogErrors
		{
			get { return _isLogErrors; }
			set
			{
				if (_isLogErrors != value)
					_isNeedReInitLogger = true;
				_isLogErrors = value;
			}
		}

		#endregion
	}
}
